<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\card\info;

class Subscribe extends \longbingcore\diy\BaseSubscribe
{
    public function onDiyUserInfo($data)
    {
        return $data;
    }
    public function onDiyCreateCard($data)
    {
        return $data;
    }
    public function onDiyChangeStaff($data)
    {
        $userModel = new \app\card\model\User();
        $last_staff_id = $userModel->where("id", $this->getUserId())->value("last_staff_id ");
        if($last_staff_id) {
            $staff_model = new \app\Common\model\LongbingUserInfo();
            $staff_info = $staff_model->getStaff($last_staff_id, $this->_uniacid);
            if(!empty($staff_info)) {
                $job_model = new \app\card\model\Job();
                $job_name = $job_model->where("id", $staff_info["job_id"])->value("name");
                $staff_info["job_name"] = $job_name;
                $staff_info = longbing_array_columns([$staff_info], ["id", "fans_id", "name", "avatar", "job_name"]);
                $staff_info = $staff_info[0];
            }
            $data["dataList"] = $staff_info;
        }
        return $data;
    }
    public function onAddUcenterCompoent()
    {
        $userInfo = "{\"title\":\"用户信息\",\"type\":\"userInfo\",\"icon\":\"iconyonghuxinxi\",\"isDelete\":false,\"addNumber\":1,\"attr\":[{\"title\":\"字体颜色\",\"type\":\"ColorPicker\",\"name\":\"fontColor\"},{\"title\":\"背景图片\",\"type\":\"UploadImage\",\"desc\":\"750*440\",\"name\":\"bgImage\"}],\"data\":{\"nickName\":\"用户昵称\",\"avatarUrl\":\"https://retail.xiaochengxucms.com/defaultAvatar.png\",\"nickText\":\"更新我的个人资料\",\"fontColor\":\"#F9DEAF\",\"bgImage\":[{\"url\":\"http://longbingcdn.xiaochengxucms.com/admin/diy/user_bg.jpg\"}]}}";
        $createCard = "{\"title\":\"创建名片\",\"type\":\"createCard\",\"icon\":\"iconchuangjianmingpian\",\"isDelete\":false,\"addNumber\":1,\"data\":{\"createText\":\"创建我的名片\",\"createBtn\":\"创建名片\"}}";
        $changeStaff = "{\"title\":\"切换销售\",\"type\":\"changeStaff\",\"icon\":\"iconqiehuanmingpian-copy\",\"isDelete\":false,\"addNumber\":1,\"attr\":[{\"title\":\"模板名称\",\"type\":\"Input\",\"name\":\"title\"},{\"title\":\"是否显示更多\",\"type\":\"Switch\",\"name\":\"isShowMore\"}],\"data\":{\"title\":\"切换销售\",\"isShowMore\":true},\"dataList\":[]}";
        $distribution = "\n {\"title\":\"分销申请\",\"type\":\"distributionApply\",\"icon\":\"iconDistributionApply\",\"isDelete\":true,\"addNumber\":1,\"data\":{\"title\":\"分销申请\",\"img\":\"http://longbingcdn.xiaochengxucms.com/admin/shop/distridution.jpg\"}}";
        $compoentList = [json_decode($userInfo, true), json_decode($createCard, true), json_decode($changeStaff, true)];
        $app_name = config("app.AdminModelList")["app_model_name"];
        if(!in_array($app_name, ["longbing_web"])) {
            $compoentList[] = json_decode($distribution, true);
        }
        return $compoentList;
    }
    public function onUserLoginApp($user)
    {
        $userService = new \app\card\service\UserService();
        $userService->initFirstUserToStaff($user["id"], $user["uniacid"]);
    }
}

?>